//
//  ZH_EvaluationInformationViewController.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/26.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_EvaluationInformationViewController.h"
#import "ZH_EvaluationInforTableViewCell.h"
#import "ZH_EvaluationImageTableViewCell.h"
#import "ZH_EvaluationGoodApplyTableViewCell.h"
#import "ZH_CommentsTableViewCell.h"
@interface ZH_EvaluationInformationViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,weak)UITableView *tableView;
@end

@implementation ZH_EvaluationInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUserInterface];
}

- (void)initUserInterface{
    self.navigationItem.title = @"评价详情";
    self.view.backgroundColor = kCommonBackgroudColor;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"发表回复" style:UIBarButtonItemStylePlain target:self action:nil];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.view);
    }];
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 3;
    }
    else if (section == 1){
        return 2;
    }
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        return FITSCALE(44);
    }
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    if (section == 0) {
        return FITSCALE(9);
    }
    return CGFLOAT_MIN;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        UIView *view = [UIView createViewWithBackgroundColor:kFontColorWhite];
        UIView *lineViewss = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [view addSubview:lineViewss];
        [lineViewss mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.equalTo(view);
            make.height.mas_equalTo(FITSCALE(1));
        }];
        UIView *lineView = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#00C9AE"]];
        [view addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(view);
            make.width.mas_equalTo(FITSCALE(4));
            make.height.mas_equalTo(FITSCALE(18));
            make.left.equalTo(view).offset(FITSCALE(11));
        }];
        UILabel *label = [UILabel createLabelWithText:@"全部评论" font:kFontSize_30];
        label.font = [UIFont boldSystemFontOfSize:15];
        [view addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(view);
            make.left.equalTo(lineView.mas_right).offset(FITSCALE(8));
        }];
        UIView *lineViews = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [view addSubview:lineViews];
        [lineViews mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(view);
            make.height.mas_equalTo(FITSCALE(1));
        }];
        return view;

    }
    return nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 0) {
            ZH_EvaluationInforTableViewCell *cell = [ZH_EvaluationInforTableViewCell cellWithTableView:tableView];
            return cell;
        }
        else if(indexPath.row == 1){
            ZH_EvaluationImageTableViewCell *cell = [ZH_EvaluationImageTableViewCell cellWithTableView:tableView];
            [cell updateUiForData:@[@"",@"",@""].mutableCopy];
            return cell;
        }
        else if (indexPath.row == 2){
            ZH_EvaluationGoodApplyTableViewCell *cell = [ZH_EvaluationGoodApplyTableViewCell cellWithTableView:tableView];
            return cell;
        }
    }
    else if (indexPath.section == 1){
        ZH_CommentsTableViewCell *cell = [ZH_CommentsTableViewCell cellWithTableView:tableView];
        return cell;
    }
    return nil;
}

#pragma mark - getter,setter
- (UITableView *)tableView{
    if (!_tableView) {
        UITableView *tableView = [UITableView createTableViewWithDelegateTarget:self];
        tableView.backgroundColor = kCommonBackgroudColor;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [tableView setCellAutoAdaptationForEstimatedRowHeight:FITSCALE(100)];
        [self.view addSubview:_tableView = tableView];
    }
    return _tableView;
}



@end
